part of request;

late SharedPreferences _preferences;

class Token {
  static Future<void> init() async {
    _preferences = await SharedPreferences.getInstance();
    String? token = _preferences.getString(_Tx.token);
    if (token != null) set(token);
  }

  static void set(String token) {
    _dio.options.headers[_Tx.auth] = token;
    _preferences.setString(_Tx.token, token);
  }

  static void clear() {
    _dio.options.headers[_Tx.auth] = null;
    _preferences.remove(_Tx.token);
  }
}
